<!-- 单个问题 -->

<template>
  <div class="QuestionnaireDetail-MyQuestion">
    <OurItem v-for="item in questionList" :key="item.id" :obj="item">
      <component :is="CORE.keyPre(item.type, 'My')" :obj="item" />
    </OurItem>
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import MyQuestion from '@questionnaire/views/Detail/MyQuestion'

// ============================== 导出组件 ============================== //

export default CORE.extend(MyQuestion, {

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb(), CORE.mixWeb('answer', 'answer_')],

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: {
    /**
     * 问题列表
     */
    questionList() {
      return this.one.questionList.filter(({ checkList }) => {
        for (const [no, letter] of checkList) { // 关联判断
          const value = this.answer_one[`no_${no}`]
          if (CORE.isEmpty(value) || !value.includes(letter)) return false
        }
        return true
      })
    },

    /**
     * 表单对象
     */
    form() {
      return this.answer_one
    },

    /**
     * 是否禁用
     */
    disabled() {
      return true
    },
  },
})
</script>
